package com.funfitnessapp;

import java.text.DecimalFormat;
import java.util.Scanner;

/**
 * Program to calculate the BMI number and Status according to the CDC
 * 
 * @author Matt Nanney
 *
 */
public class BMI {
        
        //Create the integers to hold the values input by the user.

        private double weightInPounds;
        private double heightInInches;
        private double bmi;
        
        public BMI(){
                
        }
        //Only for testing
        /**
        private String whatIsYourBMI (double w, double ft, double in){
                bmi = calculateBMI(w, ft, in);
                String status = weightStatus(bmi);
                DecimalFormat df = new DecimalFormat("#.##");
                return "Your BMI is: " + df.format(bmi) + ". Your status is: " + status + ". ";
        }*/
        /**
         * Calculates the user's actual BMI number
         * 
         * Takes in weight, feet in height, and inches in height
         * 
         * Returns the BMI number
         */
        protected double calculateBMI(double w, double in){
                weightInPounds = w;
                heightInInches = in;
                
                bmi = (weightInPounds/(heightInInches*heightInInches) * 703);
                return bmi;
        }
        
        /**
         * 
         * @param BMI - the user's BMI number
         * @return String - The category the user's BMI places them in 
         *                      according to the CDC
         */
        protected String weightStatus(double bmi) throws NullPointerException{
                if (bmi < 18.5){
                        return "Underweight";
                }
                else if (bmi < 25 && bmi >= 18.5){
                        return "Normal";
                }
                else if (bmi < 30 && bmi >= 25){
                        return "Overweight";
                }
                else if (bmi > 25){
                        return "Obese";
                }
                else{
                        throw new NullPointerException ("BMI Number hasn't been found.");
                }
        }
        // Only for testing
        /**
        public static void main (String [] args){
                BMI bmiObj = new BMI ();
                System.out.println("Please input your weight:");
                Scanner reader = new Scanner(System.in);
                int weight = Integer.parseInt(reader.nextLine());
                System.out.println("Please input your height in inches:");
                int height = Integer.parseInt(reader.nextLine());
                System.out.println(bmiObj.whatIsYourBMI(weight, 0, height));
        }*/
}